package com.jake.springboot.threadpool.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AsyncTask {

    /**
     * myTaskAsyncPool即配置线程池的方法名，此处如果不写自定义线程池的方法名，会使用默认的线程池。
     */
    @Async("beanThreadPool")
//    @Async
    public void doTask1(int i) {
        log.info("Task" + i + " started.");
    }

    @Async
    public void doTask2(int i) {
        if (i > 60) {
            System.out.println(1 / 0);
        }
        log.info("Native Task" + i + " started");
    }
}
